/*
 * #%L
 * SwiftUIDataAccessLayer
 * $Id:$
 * $HeadURL:$
 * %%
 * Copyright (C) 2011 - 2012 Linkwithweb
 * %%
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as
 * published by the Free Software Foundation, either version 3 of the 
 * License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public 
 * License along with this program.  If not, see
 * <http://www.gnu.org/licenses/gpl-3.0.html>.
 * #L%
 */
package com.linkwithweb.products.swiftui.rowmapper;

import java.sql.ResultSet;
import java.sql.SQLException;

import com.linkwithweb.products.swiftui.dataobject.FrameworkReportColumn;

/**
 * This Class Loads ReportColumns
 * 
DROP TABLE IF EXISTS `automata`.`frm_report_columns`;
CREATE TABLE  `automata`.`frm_report_columns` (
  `COLUMN_KEY` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `COLUMN_ID` varchar(45) DEFAULT NULL,
  `COLUMN_NAME` varchar(45) DEFAULT NULL,
  `REPORT_ID` varchar(45) DEFAULT NULL,
  `COLUMN_DESCRIPTION` varchar(45) DEFAULT NULL,
  `COLUMN_LABEL` varchar(45) DEFAULT NULL,
  `COLUMN_DEFAULT_VALUE` varchar(45) DEFAULT NULL,
  `COLUMN_TYPE` varchar(45) DEFAULT NULL,
  `COLUMN_GROUP` varchar(45) DEFAULT NULL,
  `COLUMN_FORMULAE` varchar(45) DEFAULT NULL,
  `EDITABLE` tinyint(1) NOT NULL,
  `DISPLAYABLE` tinyint(1) NOT NULL,
  `TRUE_VALUE` varchar(45) DEFAULT NULL,
  `FALSE_VALUE` varchar(45) DEFAULT NULL,
  `COLUMN_DEFAULT_FORMAT` varchar(45) DEFAULT NULL,
  `IS_FILTER_ENABLED` tinyint(1) NOT NULL,
  `DISPLAY_WIDTH` int(10) unsigned NOT NULL,
  `HYPERLINK_TEXT` varchar(100) NOT NULL,
  `IS_ACTIVE` tinyint(1) NOT NULL,
  `IDENTIFIER` varchar(45) DEFAULT NULL,
  `IDENTIFIER_ROLE` varchar(45) DEFAULT NULL,
  `CREATED_BY` int(10) unsigned NOT NULL,
  `CREATED_DATE` datetime NOT NULL,
  `MODIFIED_BY` int(10) unsigned NOT NULL,
  `MODIFIED_DATE` datetime NOT NULL,
  `FILTER_TYPE` varchar(5) DEFAULT NULL,
  PRIMARY KEY (`COLUMN_KEY`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 * 
 * @author ashwin
 * 
 */
public class ReportColumnRowMapper extends AbstractRowMapper  {

	public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
		FrameworkReportColumn reportColumn = new FrameworkReportColumn();

		reportColumn.setColumnKey(rs.getLong("COLUMN_KEY"));
		reportColumn.setColumnId(rs.getString("COLUMN_ID"));
		reportColumn.setColumnName(rs.getString("COLUMN_NAME"));
		reportColumn.setColumnLabel(rs.getString("COLUMN_LABEL"));
		reportColumn.setReportId(rs.getString("REPORT_ID"));
		reportColumn.setColumnDescription(rs.getString("COLUMN_DESCRIPTION"));
		reportColumn.setColumnDefaultValue(rs.getString("COLUMN_DEFAULT_VALUE"));
		reportColumn.setColumnType(rs.getString("COLUMN_TYPE"));

		reportColumn.setColumnGroup(rs.getString("COLUMN_GROUP"));
		reportColumn.setColumnOrder(rs.getInt("COLUMN_ORDER"));
		reportColumn.setColumnFormulae(rs.getString("COLUMN_FORMULAE"));
		reportColumn.setEditable(rs.getBoolean("EDITABLE"));
		reportColumn.setDisplayable(rs.getBoolean("DISPLAYABLE"));

		reportColumn.setTrueValue(rs.getString("TRUE_VALUE"));
		reportColumn.setFalseValue(rs.getString("FALSE_VALUE"));
		reportColumn.setColumnDefaultFormat(rs.getString("COLUMN_DEFAULT_FORMAT"));
		reportColumn.setFilterEnabled(rs.getBoolean("IS_FILTER_ENABLED"));
		reportColumn.setDisplayWidth(rs.getInt("DISPLAY_WIDTH"));
		reportColumn.setHyperlinkText(rs.getString("HYPERLINK_TEXT"));
		reportColumn.setFilterType(rs.getString("FILTER_TYPE"));
		
		return mapDefaultColumns(reportColumn,rs);
	}

}